package com.sc.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sc.mapper.TitletypeMapper;
import com.sc.pojo.Title;
import com.sc.pojo.Titletype;
import com.sc.service.TitleTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.nio.file.ProviderNotFoundException;
import java.util.List;

@Service
@Transactional
public class TitleTypeServiceImpl implements TitleTypeService {
    @Autowired
    TitletypeMapper mapper;
    @Override
    public List<Titletype> showAll() {
        return mapper.showAll();
    }

    @Override
    public PageInfo<Titletype> show(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<Titletype> titletypes = mapper.showAll();
        return new PageInfo<>(titletypes);
    }

    @Override
    public int add(Titletype titletype) {
        return mapper.insertSelective(titletype);
    }

    @Override
    public int deleteAll(Integer[] ids) {
        return mapper.deleteAll(ids);
    }

    @Override
    public Titletype showOne(Integer id) {
        return mapper.selectByPrimaryKey(id);
    }

    @Override
    public int delete(Integer id) {
        return mapper.deleteByPrimaryKey(id);
    }

    @Override
    public Titletype checkType(String type) {
        return mapper.checkType(type);
    }
}
